package com.example;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

public class RedisLock3 {
    Logger logger = LoggerFactory.getLogger(com.example.RedisLock3.class);
    private String lockKey = "redis_lock";
    private static int expireTime = 30;//30秒
    private static long timeout = 15*60*1000;
    @Autowired
    private RedisTemplate redisTemplate;

    public boolean lock(String randomValue){
        long startTime = System.currentTimeMillis();
        redisTemplate.opsForValue().set(lockKey, randomValue, expireTime, TimeUnit.SECONDS);
        return false;
    }
}
